package com.zy.je.common.core.constant;

import com.zy.je.common.core.utils.lang.ObjectUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author zy
 */
@Slf4j
public enum QueryType {
    /**
     * =
     **/
    EQ("eq"),
    /**
     * !=
     **/
    NE("ne"),
    /**
     * >
     **/
    GT("gt"),
    /**
     * >=
     **/
    GTE("gte"),
    /**
     * <
     **/
    LT("lt"),
    /**
     * <=
     **/
    LTE("lte"),
    /**
     * IN
     **/
    IN("in"),
    /**
     * not in
     **/
    NOT_IN("notIn"),
    /**
     * like
     **/
    LIKE("like"),
    /**
     * left like="like %xxx"
     **/
    LEFT_LIKE("lLike"),
    /**
     * right like="like xxx%"
     **/
    RIGHT_LIKE("rLike"),
    /**
     * control like="like xxx"
     **/
    CTRL_LIKE("cLike"),
    /**
     * is null
     **/
    IS_NULL("isNull"),
    /**
     * is not null
     **/
    IS_NOT_NULL("isNotNull"),
    /**
     * order by xxx asc
     **/
    ORDER_BY("orderBy"),
    /**
     * select cutom field operation
     **/
    SELECT_FIELD("selectField"),
    /**
     * none operation
     **/
    NONE("none");

    String value;

    QueryType(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    public static QueryType getInstance(String value) {
        for (QueryType it : QueryType.values()) {
            if (it.getValue().equals(value)) {
                return it;
            }
        }
        log.info("QueryType(value=" + ObjectUtil.toString(value) + ") not exists");
        return null;
    }
}